package com.myblog.controller;

import com.myblog.domain.GlobalResponse;
import com.myblog.domain.entity.Tag;
import com.myblog.services.TagService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/content/tag")
public class tagController {
    @Resource
    private TagService tagService;



    @GetMapping("/listAllTag")
    public GlobalResponse listAllTag(){
        return tagService.getAllTag();
    }

    @GetMapping("/list")
    public GlobalResponse list(Integer pageNum, Integer pageSize, Tag tag){
       return tagService.getList(pageNum,pageSize,tag);
    }

    @PostMapping()
    public GlobalResponse addTag(@RequestBody Tag tag){
        return  tagService.add(tag);
    }

    @DeleteMapping("/{id}")
    public GlobalResponse deleteTag(@PathVariable("id") Long id){
        return tagService.deleteTag(id);
    }

    @GetMapping("/{id}")
    public GlobalResponse getTag(@PathVariable("id")Long id){
        return tagService.getTag(id);
    }

    @PutMapping()
    public GlobalResponse updateTag(@RequestBody Tag tag){
        return tagService.updateTag(tag);
    }


}
